package cn.opopopo.design_pattern_learn.行为型.strategy;

public class ShoppingCart {
    private DiscountStrategy discountStrategy;

    // 可以在运行时设置策略
    public void setDiscountStrategy(DiscountStrategy strategy) {
        this.discountStrategy = strategy;
    }

    public double checkout(double originalPrice) {
        System.out.println("原价: " + originalPrice);
        double finalPrice = discountStrategy.applyDiscount(originalPrice);
        System.out.println("最终价格: " + finalPrice);
        return finalPrice;
    }
}